package com.nari.ncps.screen.service.impl.ne;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nari.ncps.screen.entity.ne.NePopupBasic;
import com.nari.ncps.screen.entity.ne.NeWindResource;
import com.nari.ncps.screen.mapper.ne.NePopupBasicMapper;
import com.nari.ncps.screen.mapper.ne.NeWindFieldBasicInfoMapper;
import com.nari.ncps.screen.mapper.ne.NeWindResourceMapper;
import com.nari.ncps.screen.service.ne.NeWindFieldBasicInfoService;
import com.nari.ncps.screen.vo.ne.WindCompanyIntroVO;
import com.nari.ncps.screen.vo.ne.WindFieldBasicInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

/**
 * <p>
 * 新能源设备状态监测表 服务实现类
 * </p>
 *
 * @author xuesong
 * @since 2025-08-23
 */
@Service
public class NeWindFieldBasicInfoServiceImpl  implements NeWindFieldBasicInfoService {
    @Autowired
    private NePopupBasicMapper nePopupBasicMapper;

    @Autowired
    private NeWindResourceMapper neWindResourceMapper;

    @Override
    public WindFieldBasicInfoVO getWindFieldBasicInfo(String orgCode) {
        if (orgCode == null) {
            orgCode = "134058";
        }
        LambdaQueryWrapper<NePopupBasic> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(NePopupBasic::getDelFlag, 0).eq(NePopupBasic::getOrgCode, orgCode);
        NePopupBasic nePopupBasic = nePopupBasicMapper.selectOne(queryWrapper);
        //获取风功率预测值的实时数据
        LambdaQueryWrapper<NeWindResource> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(NeWindResource::getDelFlag, 0).eq(NeWindResource::getOrgCode, orgCode);
        NeWindResource realData = neWindResourceMapper.selectOne(wrapper);


//        组合数据
        WindFieldBasicInfoVO vo = new WindFieldBasicInfoVO();
        vo.setWindPowerCapacity(nePopupBasic.getWindPowerCapacity());
        vo.setWindFieldCount(nePopupBasic.getWindTurbineNormal());
        vo.setDailyUtilizationHours(nePopupBasic.getWindUtilizationHours());
        vo.setWindEquipmentCount(nePopupBasic.getWindTurbineCount());
        vo.setWindPowerForecast(realData.getWindPowerForecast());

        return vo;
    }

    @Override
    public boolean saveBatch(Collection<NePopupBasic> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<NePopupBasic> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<NePopupBasic> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(NePopupBasic entity) {
        return false;
    }

    @Override
    public NePopupBasic getOne(Wrapper<NePopupBasic> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Optional<NePopupBasic> getOneOpt(Wrapper<NePopupBasic> queryWrapper, boolean throwEx) {
        return Optional.empty();
    }

    @Override
    public Map<String, Object> getMap(Wrapper<NePopupBasic> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<NePopupBasic> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }

    @Override
    public BaseMapper<NePopupBasic> getBaseMapper() {
        return null;
    }

    @Override
    public Class<NePopupBasic> getEntityClass() {
        return null;
    }
}
